import { NAV_ITEMS } from '../constants/navigation';

/**
 * 根据路径获取当前激活的导航项
 * @param {string} pathname - 当前路径
 * @returns {Object|null} 激活的导航项对象
 */
export const getActiveNavItem = (pathname) => {
  const activeItem = Object.values(NAV_ITEMS).find(item => item.path === pathname);
  return activeItem || NAV_ITEMS.HOME;
};

/**
 * 根据key获取导航项信息
 * @param {string} key - 导航项key
 * @returns {Object|null} 导航项信息
 */
export const getNavItemByKey = (key) => {
  return Object.values(NAV_ITEMS).find(item => item.key === key) || null;
};

/**
 * 获取所有主要导航项（排除创建行程）
 * @returns {Array} 主要导航项数组
 */
export const getMainNavItems = () => {
  return Object.values(NAV_ITEMS).filter(item => 
    item.key !== NAV_ITEMS.CREATE_TRIP.key
  );
};

/**
 * 获取移动端底部导航项
 * @returns {Array} 移动端导航项数组
 */
export const getMobileBottomNavItems = () => {
  return [
    NAV_ITEMS.HOME,
    NAV_ITEMS.TRIP,
    NAV_ITEMS.NEARBY,
    NAV_ITEMS.COMMUNITY,
    NAV_ITEMS.MESSAGE,
    NAV_ITEMS.PROFILE
  ];
};